import re

import requests

# 设置要监测的网页URL和关键字
keyword="早春"
url = " https://yys-xiaomi.cbg.163.com/cgi-bin/recommend.py?client_type=h5&act=recommd_by_role&search_type=role&count=15&game_channel=xiaomi&view_loc=search_cond&order_by=price%20ASC&serverid=55&skin_id=412603&page=1&exter=direct&page_session_id=0192C273-93FA-39F3-7F39-5227AD34E9A3&traffic_trace=%7B%22field_id%22%3A%22%22%2C%22content_id%22%3A%22%22%7D"

def http(url):

    result = requests.get(url)
    # 返回链接的json字符串
    return result

def unicode_to_char(text):
    # 使用正则表达式匹配所有的Unicode转义序列
    unicode_pattern = re.compile(r'\\u[0-9a-fA-F]{4}')

    # 定义一个函数，将匹配到的Unicode转义序列转换为对应的字符
    def replace_unicode(match):
        return chr(int(match.group(0)[2:], 16))

    # 使用sub方法进行替换
    result = unicode_pattern.sub(replace_unicode, text)
    # 输出转移后的字符串
    return result


# 转换并输出结果
output_text = unicode_to_char(http(url).text)
if keyword in output_text:
    print("警报：关键字 '{}' 出现在网页中！".format(keyword))
else:
    print("关键字 '{}' 未出现。".format(keyword))

